﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.EntityFrameworkCore;
using TodoApp.ResultModel;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;

namespace TodoApp.TMS_material.ProductionPlace
{
    public class TMS_PlaceAppRepository : DapperDbContrxtRepository, ITransientDependency, ITMS_PlaceAppRepository
    {
        public TMS_PlaceAppRepository(IDbContextProvider<TodoAppDbContext> dbContextProvider) : base(dbContextProvider)
        {
        }

        #region 二级联动
        public async Task<PageResponse<TMS_ProductionPlaceDto>> GetAllPlace(int id)
        {
            var result = new PageResponse<TMS_ProductionPlaceDto>();
            var dbConnection = await GetDbConnectionAsync();
            var sql = $"select * from TMS_ProductionPlace where PId={id}";
            var quer = await dbConnection.QueryAsync<TMS_ProductionPlaceDto>(sql, transaction: await GetDbTransactionAsync());
            result.PageData = quer.ToList();
            return result;

        }
        #endregion
    }
}
